# Maintainer:
pkgname=linuxptp
pkgver=4.2
pkgrel=0
pkgdesc="User space PTP stack for Linux"
url="https://linuxptp.nwtime.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	bsd-compat-headers
	linux-headers
	"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/richardcochran/linuxptp/archive/refs/tags/v$pkgver.tar.gz"
options="!check" # no tests

_bins="hwstamp_ctl nsm phc2sys phc_ctl pmc ptp4l timemaster ts2phc tz2alt"
for _bin in $_bins; do
	depends="$depends $pkgname-$_bin=$pkgver-r$pkgrel"
	subpackages="$subpackages $pkgname-$_bin:split"
done

build() {
	make \
		CC="${CC:-cc}" \
		version="$pkgver" \
		EXTRA_CFLAGS="$CFLAGS -flto=auto"
}

package() {
	make \
		prefix=/usr \
		mandir=/usr/share/man \
		DESTDIR="$pkgdir" \
		install
}

split() {
	local name="${subpkgname#"$pkgname"-}"
	pkgdesc="$pkgdesc ($name utility)"
	depends=""

	amove usr/sbin/$name
}

sha512sums="
479e512efd0573602379a9e1d8ef5c0ec9e033944cee5aed11c68cea5e8a3f7d4b6f2d11f6d6d4718282010da52c2c8629d675d9b388cc0c3d574845a913cdbb  linuxptp-4.2.tar.gz
"
